package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobGuardianQualifications;
import com.ruoyi.system.mapper.JobGuardianQualificationsMapper;
import com.ruoyi.system.service.JobGuardianQualificationsService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 监护人资质维护(JobGuardianQualifications)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:09
 */
@Service("jobGuardianQualificationsService")
public class JobGuardianQualificationsServiceImpl implements JobGuardianQualificationsService {
    @Resource
    private JobGuardianQualificationsMapper jobGuardianQualificationsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobGuardianQualifications queryById(Integer id) {
        return this.jobGuardianQualificationsDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobGuardianQualifications 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobGuardianQualifications> queryByPage(JobGuardianQualifications jobGuardianQualifications, PageRequest pageRequest) {
        long total = this.jobGuardianQualificationsDao.count(jobGuardianQualifications);
        return new PageImpl<>(this.jobGuardianQualificationsDao.queryAllByLimit(jobGuardianQualifications, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobGuardianQualifications> queryAll(JobGuardianQualifications jobGuardianQualifications) {
        return jobGuardianQualificationsDao.queryAll(jobGuardianQualifications);
    }

    /**
     * 新增数据
     *
     * @param jobGuardianQualifications 实例对象
     * @return 实例对象
     */
    @Override
    public JobGuardianQualifications insert(JobGuardianQualifications jobGuardianQualifications) {
        this.jobGuardianQualificationsDao.insert(jobGuardianQualifications);
        return jobGuardianQualifications;
    }

    /**
     * 修改数据
     *
     * @param jobGuardianQualifications 实例对象
     * @return 实例对象
     */
    @Override
    public JobGuardianQualifications update(JobGuardianQualifications jobGuardianQualifications) {
        this.jobGuardianQualificationsDao.update(jobGuardianQualifications);
        return this.queryById(jobGuardianQualifications.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobGuardianQualificationsDao.deleteById(id) > 0;
    }
}
